/*!
 * h5自适应 PC/移动
 * from https://segmentfault.com/a/1190000008721148
 * 另一个 http://www.cnblogs.com/xianyulaodi/p/5533201.html#commentform
 * Petu 2017-11-22
 */
window.onload = function()
{
    //1024 设计稿宽度;100 换算比例 100px=1rem
    getRem(750,100)
};

window.onresize = function()
{
	//1024 设计稿宽度;100 换算比例 100px=1rem
    getRem(750,100)
};

function getRem(pwidth,prem)
{
    var html = document.getElementsByTagName("html")[0];
    var oWidth = document.body.clientWidth || document.documentElement.clientWidth;
    html.style.fontSize = oWidth/pwidth*prem + "px";
}

//小米官网的写法
//!function(n){
//  var  e=n.document,
//       t=e.documentElement,
//       i=720,
//       d=i/100,
//       o="orientationchange"in n?"orientationchange":"resize",
//       a=function(){
//           var n=t.clientWidth||320;n>720&&(n=720);
//           t.style.fontSize=n/d+"px"
//       };
//       e.addEventListener&&(n.addEventListener(o,a,!1),e.addEventListener("DOMContentLoaded",a,!1))
//}(window);